package com.share.wechat.fristpage.controller;

import com.share.wechat.fristpage.entity.Test;
import com.share.wechat.fristpage.service.TestService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 测试rest接口 详细区分post个get请求
 * Created by er on 2017/9/29.
 */
@RestController
@RequestMapping("/hello")
public class Mycontroller {
    private Logger logger = Logger.getLogger(this.getClass());
    @Autowired
    private TestService testService;

    @PostMapping("show")
    public List<Test> showAll(@RequestParam(defaultValue = "张三") String name) {
        List<Test> tests = testService.getTests();
        logger.info(tests);
        logger.info(name);
        tests.add(new Test(name, 123113));
        return tests;
    }
}
